package com.pkk.components.util.enums;

import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author luffy
 * @description: 文件类型
 * @date 2019-07-06 16:04
 */
@Getter
@AllArgsConstructor
public enum FileTypeEnum {
  ai(".ai", "application/postscript"),
  aif(".aif", "audio/x-aiff"),
  aifc(".aifc", "audio/x-aiff"),
  aiff(".aiff", "audio/x-aiff"),
  asc(".asc", "text/plain"),
  asf(".asf", "video/x.ms.asf"),
  asx(".asx", "video/x.ms.asx"),
  au(".au", "audio/basic"),
  avi(".avi", "video/x-msvideo"),
  bcpio(".bcpio", "application/x-bcpio"),
  bin(".bin", "application/octet-stream"),
  cab(".cab", "application/x-cabinet"),
  cdf(".cdf", "application/x-netcdf"),
  class_(".class", "application/java-vm"),
  cpio(".cpio", "application/x-cpio"),
  cpt(".cpt", "application/mac-compactpro"),
  crt(".crt", "application/x-x509-ca-cert"),
  csh(".csh", "application/x-csh"),
  css(".css", "text/css"),
  csv(".csv", "text/comma-separated-values"),
  dcr(".dcr", "application/x-director"),
  dir(".dir", "application/x-director"),
  dll(".dll", "application/x-msdownload"),
  dms(".dms", "application/octet-stream"),
  doc(".doc", "application/msword"),
  dtd(".dtd", "application/xml-dtd"),
  dvi(".dvi", "application/x-dvi"),
  dxr(".dxr", "application/x-director"),
  eps(".eps", "application/postscript"),
  etx(".etx", "text/x-setext"),
  exe(".exe", "application/octet-stream"),
  ez(".ez", "application/andrew-inset"),
  gif(".gif", "image/gif"),
  gtar(".gtar", "application/x-gtar"),
  gz(".gz", "application/gzip"),
  gzip(".gzip", "application/gzip"),
  hdf(".hdf", "application/x-hdf"),
  htc(".htc", "text/x-component"),
  hqx(".hqx", "application/mac-binhex40"),
  html(".html", "text/html"),
  htm(".htm", "text/html"),
  ice(".ice", "x-conference/x-cooltalk"),
  ief(".ief", "image/ief"),
  iges(".iges", "model/iges"),
  igs(".igs", "model/iges"),
  jar(".jar", "application/java-archive"),
  java(".java", "text/plain"),
  jnlp(".jnlp", "application/x-java-jnlp-file"),
  jpeg(".jpeg", "image/jpeg"),
  jpe(".jpe", "image/jpeg"),
  jpg(".jpg", "image/jpeg"),
  js(".js", "application/x-javascript"),
  jsp(".jsp", "text/plain"),
  kar(".kar", "audio/midi"),
  latex(".latex", "application/x-latex"),
  lha(".lha", "application/octet-stream"),
  lzh(".lzh", "application/octet-stream"),
  man(".man", "application/x-troff-man"),
  mathml(".mathml", "application/mathml+xml"),
  me(".me", "application/x-troff-me"),
  mesh(".mesh", "model/mesh"),
  mid(".mid", "audio/midi"),
  midi(".midi", "audio/midi"),
  mif(".mif", "application/vnd.mif"),
  mol(".mol", "chemical/x-mdl-molfile"),
  movie(".movie", "video/x-sgi-movie"),
  mov(".mov", "video/quicktime"),
  mp2(".mp2", "audio/mpeg"),
  mp3(".mp3", "audio/mpeg"),
  mpeg(".mpeg", "video/mpeg"),
  mpe(".mpe", "video/mpeg"),
  mpga(".mpga", "audio/mpeg"),
  mpg(".mpg", "video/mpeg"),
  ms(".ms", "application/x-troff-ms"),
  msh(".msh", "model/mesh"),
  msi(".msi", "application/octet-stream"),
  nc(".nc", "application/x-netcdf"),
  oda(".oda", "application/oda"),
  ogg(".ogg", "application/ogg"),
  pbm(".pbm", "image/x-portable-bitmap"),
  pdb(".pdb", "chemical/x-pdb"),
  pdf(".pdf", "application/pdf"),
  pgm(".pgm", "image/x-portable-graymap"),
  pgn(".pgn", "application/x-chess-pgn"),
  png(".png", "image/png"),
  pnm(".pnm", "image/x-portable-anymap"),
  ppm(".ppm", "image/x-portable-pixmap"),
  ppt(".ppt", "application/vnd.ms-powerpoint"),
  ps(".ps", "application/postscript"),
  qt(".qt", "video/quicktime"),
  ra_pn(".ra", "audio/x-pn-realaudio"),
  ra(".ra", "audio/x-realaudio"),
  ram(".ram", "audio/x-pn-realaudio"),
  ras(".ras", "image/x-cmu-raster"),
  rdf(".rdf", "application/rdf+xml"),
  rgb(".rgb", "image/x-rgb"),
  rm(".rm", "audio/x-pn-realaudio"),
  roff(".roff", "application/x-troff"),
  rpm(".rpm", "application/x-rpm"),
  x_rpm(".rpm", "audio/x-pn-realaudio"),
  rtf(".rtf", "application/rtf"),
  rtx(".rtx", "text/richtext"),
  ser(".ser", "application/java-serialized-object"),
  sgml(".sgml", "text/sgml"),
  sgm(".sgm", "text/sgml"),
  sh(".sh", "application/x-sh"),
  shar(".shar", "application/x-shar"),
  silo(".silo", "model/mesh"),
  sit(".sit", "application/x-stuffit"),
  skd(".skd", "application/x-koan"),
  skm(".skm", "application/x-koan"),
  skp(".skp", "application/x-koan"),
  skt(".skt", "application/x-koan"),
  smi(".smi", "application/smil"),
  smil(".smil", "application/smil"),
  snd(".snd", "audio/basic"),
  spl(".spl", "application/x-futuresplash"),
  src(".src", "application/x-wais-source"),
  sv4cpio(".sv4cpio", "application/x-sv4cpio"),
  sv4crc(".sv4crc", "application/x-sv4crc"),
  svg(".svg", "image/svg+xml"),
  swf(".swf", "application/x-shockwave-flash"),
  t(".t", "application/x-troff"),
  tar(".tar", "application/x-tar"),
  tar_gz(".tar.gz", "application/x-gtar"),
  tcl(".tcl", "application/x-tcl"),
  tex(".tex", "application/x-tex"),
  texi(".texi", "application/x-texinfo"),
  texinfo(".texinfo", "application/x-texinfo"),
  tgz(".tgz", "application/x-gtar"),
  tiff(".tiff", "image/tiff"),
  tif(".tif", "image/tiff"),
  tr(".tr", "application/x-troff"),
  tsv(".tsv", "text/tab-separated-values"),
  txt(".txt", "text/plain"),
  ustar(".ustar", "application/x-ustar"),
  vcd(".vcd", "application/x-cdlink"),
  vrml(".vrml", "model/vrml"),
  vrml_x(".vxml", "application/voicexml+xml"),
  wav(".wav", "audio/x-wav"),
  wbmp(".wbmp", "image/vnd.wap.wbmp"),
  wmlc(".wmlc", "application/vnd.wap.wmlc"),
  wmlsc(".wmlsc", "application/vnd.wap.wmlscriptc"),
  wmls(".wmls", "text/vnd.wap.wmlscript"),
  wml(".wml", "text/vnd.wap.wml"),
  wrl(".wrl", "model/vrml"),
  wtls_ca_certificate(".wtls-ca-certificate", "application/vnd.wap.wtls-ca-certificate"),
  xbm(".xbm", "image/x-xbitmap"),
  xht(".xht", "application/xhtml+xml"),
  xhtml(".xhtml", "application/xhtml+xml"),
  xls(".xls", "application/vnd.ms-excel"),
  xml(".xml", "application/xml"),
  xpm(".xpm", "image/x-xpixmap"),
  xsl(".xsl", "application/xml"),
  slt(".xslt", "application/xslt+xml"),
  xul(".xul", "application/vnd.mozilla.xul+xml"),
  xwd(".xwd", "image/x-xwindowdump"),
  xyz(".xyz", "chemical/x-xyz"),
  z(".z", "application/compress"),
  zip(".zip", "application/zip");

  private String suffix;
  private String mime;

  public static String getSuffixByMime(String mime) {
    return Arrays.stream(FileTypeEnum.values()).filter(e -> e.getMime().equals(mime)).findFirst().get().suffix;
  }
}
